package com.ibeetl.admin.core.util;

import com.ibeetl.admin.core.entity.CoreOrg;
import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.service.CorePlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserUtil {

    @Autowired
    protected CorePlatformService corePlatformService;

    /**
     * 获取当前登录用户的id
     * @return
     */
    public Long getUserId(){
        return this.corePlatformService.getCurrentUserId();
    }

    /**
     * 获取当前用户会话
     * @return
     */
    public CoreUser getCurrentUser(){
        return this.corePlatformService.getCurrentUser();
    }

    /**
     * 获取当前用户机构信息
     * @return
     */
    public CoreOrg getCurrentOrg(){
        return this.corePlatformService.getCurrentOrg();
    }

    /**
     * 判断用户是否是超级管理员
     * @param user
     * @return
     */
    public boolean isSupperAdmin(CoreUser user){
        return this.corePlatformService.isSupperAdmin(user);
    }

    /**
     * 判断当前用户是否是超级管理员
     * @return
     */
    public boolean isSupperAdmin(){
        return this.isSupperAdmin(this.getCurrentUser());
    }

}
